package thread_ex;

import java.util.Random;

import javax.swing.JOptionPane;

class ThreadStop extends Thread{
	boolean ThreadFlag = false;
	
	public void run(){
		ThreadFlag = true;
		Random rnd = new Random();
		while(ThreadFlag){
			int n = rnd.nextInt(100);
			System.out.println("Random : " + n);
		}
	}
	
	public void stopThread(){
		ThreadFlag = false;
		System.out.println("Stop");
	}
}

public class Test02_ThreadStop {

	public static void main(String[] args) {
		ThreadStop ts = new ThreadStop();
		ts.start();
		try{
			Thread.sleep(3000);
		}catch(Exception e){
			JOptionPane.showMessageDialog(null, "읭?");
		}
		ts.stopThread();
	}

}
